﻿<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%option explicit%>
<%
Dim RZ_IN
RZ_IN=1
%>
<!--#include file="../conn.inc.asp" -->
<!--#include file="admin_inc/admin.function.asp" -->
<%
'作者：山林客（ah_bill）
'博客：http://ruizhinet.blog.163.com
'网站：http://www.ruizhinet.cn
'本信息不会影响您网站的正常访问，请保留
checkadmin(1)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>选择记录</title>
<link type="text/css" href="style/style.css" rel="stylesheet" rev="stylesheet"/>
<script type="text/javascript" language="javascript" src="admin_js/net.js"></script>
<script type="text/javascript" src="admin_js/common.js"></script>
<script type="text/javascript">
<!--
function CopyIds()
{
	var idels=document.getElementsByName("id");
	var vals="";
	var j=0;
	for(var i=0;i<idels.length;i++){
		if(idels[i].checked==true){
			vals+=","+idels[i].value;
			j++;
		}
	}
	var flag=true;
	if(j>=10){
		flag=confirm("选择的记录过多，可能导致SQL语句不能运行\r\n如果是同一父亲分类，建议通过指定path属性来筛选\r\n您确定要执行吗？");
	}
	if(flag){
		if(vals!="")
			vals=vals.substring(1);
		var idbox="<%=request.querystring("idbox")%>";
		if (isIE()) {
			window.opener.document.rzform(idbox).focus();							
			window.opener.document.rzform(idbox).value=vals;
			window.opener=null;
			window.close();
		} else {
			parent.opener.document.getElementById(idbox).value=vals;
			top.close();
		}
	}else{
		var idbox="<%=request.querystring("idbox")%>";
		if (isIE()) {
			window.opener.rzform(idbox).focus();							
			window.opener.document.rzform(idbox).value="";
			window.opener=null;
			window.close();
		} else {
			parent.opener.document.getElementById(idbox).value="";
			top.close();
		}
	}
}
//-->
</script>
</head>
<body style="margin:0px;">
<%Dim act,stype,fenlei
act=Trim(request.querystring("act"))
stype=Trim(request.querystring("type"))
Select Case stype
	Case "article":
		fenlei=1
	Case "product":
		fenlei=2
	Case "photo"
		fenlei=3
	Case "job":
		fenlei=7
	Case "guestbook"
		fenlei=5
End select
%>
<%If act="typelist" Or act="typepath" Or (act="tsid" And stype="type") Or act="typeparent" Then %>
<table class="table_400" cellspacing="0" cellpadding="0">
<th class='tdcenter'>选择</th>
<th class='tdcenter'>ID</th>
<th class='tdcenter'>分类名称</th>
</tr>
<%
dim rst,sqlt,rowcount,visible
Set rst = Server.CreateObject("ADODB.Recordset")
If act="typelist" Or act="typepath" Then 
sqlt = "select * from [c_type] where parentid=0 and fenlei="&fenlei&" order by theorder"
ElseIf act="typeparent" Then 
sqlt = "select * from [c_type] where parentid=0 and havechild=1 and fenlei<>4 order by theorder"
Else
sqlt = "select * from [c_type] where parentid=0 and fenlei<>4 and fenlei<>5 and fenlei<>7  order by theorder"
End If 
rst.open sqlt,conn,1,1
rowcount=1
If Not rst.eof Then 
Do While Not rst.eof
	rowcount=rowcount+1	
	response.write("<tr class='row'>")
	If act="typelist" Then 
	response.write("<td class='tdcenter'><input type='checkbox' name='id' value='"&rst("id")&"' onclick='chkRow(this);'/></td>")
	ElseIf act="typepath" Then
	response.write("<td class='tdcenter'><input type='radio' name='id' value='"&CutPath(rst("path"))&"'/></td>")
	Else
	response.write("<td class='tdcenter'><input type='radio' name='id' value='"&rst("id")&"'/></td>")
	End If 
	response.write("<td class='tdcenter'>"&rst("id")&"</td>")
	response.write("<td>"&rst("name"))
	If rst("visible")=0 Then
	response.write("(隐藏)")
	End If 
	response.write("</td>")
	response.write("</tr>")
	PrintChild(rst("id"))
rst.movenext
Loop
Else
response.write("<script type='text/javascript'>alert('没有符合条件的记录');</script>")
End If 
rst.close
Set rst=Nothing
%>
<%
Function PrintChild(parentid)
dim rsp,sqlp,rowcount,i
Set rsp = Server.CreateObject("ADODB.Recordset")
If act="typelist" Or act="typepath" Then 
sqlp = "select * from [c_type] where parentid="&parentid&" and fenlei="&fenlei&" order by theorder"
ElseIf act="typeparent" Then 
sqlp = "select * from [c_type] where parentid="&parentid&" and havechild=1 and fenlei<>4 order by theorder"
Else
sqlp = "select * from [c_type] where parentid="&parentid&" and fenlei<>4 and fenlei<>5 and fenlei<>7  order by theorder"
End If 
rsp.open sqlp,conn,1,1
Do While Not rsp.eof
	rowcount=rowcount+1	
	response.write("<tr class='row'>")
	If act="typelist" Then 
	response.write("<td class='tdcenter'><input type='checkbox' name='id' value='"&rsp("id")&"' onclick='chkRow(this);'/></td>")
	ElseIf act="typepath" Then
	response.write("<td class='tdcenter'><input type='radio' name='id' value='"&CutPath(rsp("path"))&"'/></td>")
	Else
	response.write("<td class='tdcenter'><input type='radio' name='id' value='"&rsp("id")&"'/></td>")
	End If 
	response.write("<td class='tdcenter'>"&rsp("id")&"</td>")
	response.write("<td>")
	For i=1 To rsp("thelevel")-2
	response.write("&nbsp;&nbsp;")
	Next
	If rsp("thelevel")>2 Then
	response.write("└")
	End If 
	response.write(rsp("name"))
	If rsp("visible")=0 Then
	response.write("(隐藏)")
	End If 
	response.write("</td>")
	response.write("</tr>")
	PrintChild(rsp("id"))
rsp.movenext
Loop
rsp.close
Set rsp=Nothing
End Function 
%>
<tr><td colspan="3" class="tdcenter">
<%
If act="typelist" Then 
response.write("需要选择所有相关分类，包括子分类")
ElseIf act="typepath" Then 
response.write("只需选择父亲分类")
ElseIf act="typeparent" Then 
response.write("只显示有子分类的分类")
End If
%>
<input type="button" name="sel" value="选择" onclick="CopyIds();"/></td></tr>
</table>
<%End If%>

<%If (act="tsid" And stype="special") then%>
<table class="table_400" cellspacing="0" cellpadding="0">
<th class="tdcenter">选择</th>
<th class="tdcenter">ID</th>
<th class="tdcenter">专题名称（中）</th>
</tr>
<%
sql="select * from [c_special] order by id desc"
Set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
If Not rs.eof Then 
Do While Not rs.eof 
response.write("<tr class='row'  class='tdcenter'>")
response.write("<td class='tdcenter'><input type='radio' name='id' id='id' value='"&rs("id")&"'/></td>")
response.write("<td class='tdcenter'>"&rs("id")&"</td>")
response.write("<td class='tdcenter'>"&rs("specialname"))
If rs("visible")=0 Then
response.write("(隐藏)")
End If 
response.write("</td>")
response.write("</tr>")
rs.movenext
Loop
Else
response.write("<script type='text/javascript'>alert('没有符合条件的记录');</script>")
End If 
rs.close
Set rs=nothing
%>
<tr><td colspan="3" class="tdcenter">
<input type="button" name="sel" value="选择" onclick="CopyIds();"/></td></tr>
</table>
<%End if%>
<%If act="ad" Then
Dim ad_type
Select Case stype
Case "text":
ad_type=1
Case "photo":
ad_type=2
Case "flash":
ad_type=3
Case "code":
ad_type=4
End Select 
%>
<table class="table_400" cellspacing="0" cellpadding="0">
<th class="tdcenter">选择</th>
<th class="tdcenter">ID</th>
<th class="tdcenter">广告标题</th>
</tr>
<%
dim rs,sql
sql="select * from [c_advertise] where ad_type="&ad_type&" order by id desc"
Set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
If Not rs.eof Then 
Do While Not rs.eof 
response.write("<tr class='row'  class='tdcenter'>")
response.write("<td class='tdcenter'><input type='checkbox' name='id' id='id' value='"&rs("id")&"' onclick='chkRow(this);'/></td>")
response.write("<td class='tdcenter'>"&rs("id")&"</td>")
response.write("<td class='tdcenter'>"&rs("ad_alt"))
response.write("</td>")
response.write("</tr>")
rs.movenext
Loop
Else
response.write("<script type='text/javascript'>alert('没有符合条件的记录');</script>")
End If 
rs.close
Set rs=nothing
%>
<tr><td colspan="3" class="tdcenter">
<input type="button" name="sel" value="选择" onclick="CopyIds();"/></td></tr>
</table>
<%End if%>
<%If act="friendlink" Then
%>
<table class="table_400" cellspacing="0" cellpadding="0">
<th class="tdcenter">选择</th>
<th class="tdcenter">ID</th>
<th class="tdcenter">网站名称</th>
</tr>
<%
sql="select * from [c_friendlink] order by id"
Set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
If Not rs.eof Then 
Do While Not rs.eof 
response.write("<tr class='row'  class='tdcenter'>")
response.write("<td class='tdcenter'><input type='checkbox' name='id' id='id' value='"&rs("id")&"' onclick='chkRow(this);'/></td>")
response.write("<td class='tdcenter'>"&rs("id")&"</td>")
response.write("<td class='tdcenter'>"&rs("name"))
response.write("</td>")
response.write("</tr>")
rs.movenext
Loop
Else
response.write("<script type='text/javascript'>alert('没有符合条件的记录');</script>")
End If 
rs.close
Set rs=nothing
%>
<tr><td colspan="3" class="tdcenter">
<input type="button" name="sel" value="选择" onclick="CopyIds();"/></td></tr>
</table>
<%End if%>
<%If act="fenlei" Then %>
<table class="table_400" cellspacing="0" cellpadding="0">
<th class="tdcenter">选择</th>
<th class="tdcenter">标识</th>
<th class="tdcenter">类型</th>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='1' onclick='chkRow(this);'/></td>
<td class="tdcenter">1</td>
<td class="tdcenter">文章资讯</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='2' onclick='chkRow(this);'/></td>
<td class="tdcenter">2</td>
<td class="tdcenter">商品资讯</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='3' onclick='chkRow(this);'/></td>
<td class="tdcenter">3</td>
<td class="tdcenter">图片资讯</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='4' onclick='chkRow(this);'/></td>
<td class="tdcenter">4</td>
<td class="tdcenter">外部链接</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='5' onclick='chkRow(this);'/></td>
<td class="tdcenter">5</td>
<td class="tdcenter">留言本</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='6' onclick='chkRow(this);'/></td>
<td class="tdcenter">6</td>
<td class="tdcenter">单页分类</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='7' onclick='chkRow(this);'/></td>
<td class="tdcenter">7</td>
<td class="tdcenter">招聘信息</td>
</tr>
<tr><td colspan="3" class="tdcenter">
<input type="button" name="sel" value="选择" onclick="CopyIds();"/></td></tr>
</table>
<%End If %>
<%If act="params" Then %>
<table class="table_400" cellspacing="0" cellpadding="0">
<th class="tdcenter">选择</th>
<th class="tdcenter">请求地址必须带以下参数</th>
<th class="tdcenter">取值限制</th>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='path' onclick='chkRow(this);'/></td>
<td class="tdcenter">分类路径（path）</td>
<td class="tdcenter">非空</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='typeid' onclick='chkRow(this);'/></td>
<td class="tdcenter">分类ID（typeid）</td>
<td class="tdcenter">大于0</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='typeid' onclick='chkRow(this);'/></td>
<td class="tdcenter">专题ID（specialid）</td>
<td class="tdcenter">大于0</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='lang' onclick='chkRow(this);'/></td>
<td class="tdcenter">语言（lang）</td>
<td class="tdcenter">0或1</td>
</tr>
<tr>
<td class="tdcenter"><input type='checkbox' name='id' id='id' value='recordid' onclick='chkRow(this);'/></td>
<td class="tdcenter">记录ID（recordid）</td>
<td class="tdcenter">大于0</td>
</tr>
<tr><td colspan="3" class="tdcenter">
<input type="button" name="sel" value="选择" onclick="CopyIds();"/></td></tr>
</table>
<%End If %>
</body>
</html>